<template>
  <normal-layout>
    <div class="container">
      <div style="margin: 10px">
        <span>选择年月查询工资</span>
        <el-date-picker
          v-model="dateValue"
          value-format="yyyy-MM"
          type="month"
          placeholder="选择月"
          @change="getData">
        </el-date-picker>
      </div>
      <salary-table :salary-data="salaryData"></salary-table>
    </div>
  </normal-layout>
</template>

<script>
  import SalaryTable from "../../components/Statistics/SalaryTable";
  import NormalLayout from "../../layouts/NormalLayout";
  export default {
    name: "Salary",
    components: {NormalLayout, SalaryTable},
    data(){
      return{
        /*按月份查询的月份*/
        dateValue:'',
        /*工资数据*/
        salaryData: [],
      }
    },
    mounted() {
    },
    methods:{
      async getData(){
        let mydata={
          date:this.dateValue,
        }
        console.log(mydata);
        this.$axios.$post('/get_salary',mydata).then((res)=>{
          if(res==='0'){
            this.$message({
              showClose: true,
              message: '输入月份无效',
              type: 'error'
            });
            this.dateValue=''
            return;
          }
          this.salaryData=res;
          console.log(res);
          console.log(this.salaryData);
        })
      }
    }
  }
</script>

<style scoped>

</style>
